package com.mjw.zstu.controller;

import com.mjw.zstu.resultDto.JsonResult;
import com.mjw.zstu.service.ExhibitionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

@CrossOrigin
@RestController
@RequestMapping("app")
public class Appcontroller {
    @Autowired
    ExhibitionService exhibitionService;
    @RequestMapping("banner")
    public JsonResult banner(){
        return exhibitionService.getbanner();
    }
    @RequestMapping("nobanner")
    public JsonResult notBanner(){
        return exhibitionService.getnotBanner();
    }
    @RequestMapping("addbanner")
    public JsonResult addbanner(@RequestParam String banners){
        String[] s=  banners.split(",");
        int[] l= Arrays.stream(s).mapToInt(Integer::parseInt).toArray();
        return exhibitionService.addbanner(l);
    }
    @RequestMapping("bannerdelete")
    public JsonResult deletebanner(int id){
        return exhibitionService.deleteBanner(id);
    }
    @RequestMapping("recommend")
    public JsonResult recommend(){
        return exhibitionService.getrecommend();
    }
    @RequestMapping("norecommend")
    public JsonResult notRecommend(){
        return exhibitionService.getnotRecommend();
    }
    @RequestMapping("addrecommend")
    public JsonResult addrecommend(@RequestParam String banners){
        String[] s=  banners.split(",");
        int[] l= Arrays.stream(s).mapToInt(Integer::parseInt).toArray();
        return exhibitionService.addrecommend(l);
    }
    @RequestMapping("recommenddelete")
    public JsonResult deleterecommend(int id){
        return exhibitionService.deleterecommend(id);
    }
}
